destroy: function() {
this._cancellable.cancel();
-
- if (this._updateAnimationTimeoutId) {
- GLib.source_remove (this._updateAnimationTimeoutId);
- this._updateAnimationTimeoutId = 0;
- }
+ this._removeAnimationTimeout();
let i;
let keys = Object.keys(this._fileWatches);
this._settingsChangedSignalId = 0;
},
+ updateResolution: function() {
+ if (this._animation) {
+ this._removeAnimationTimeout();
+ this._updateAnimation();
+ }
+ },
+
_setLoaded: function() {
if (this.isLoaded)
return;
this._fileWatches[filename] = signalId;
},
+ _removeAnimationTimeout: function() {
+ if (this._updateAnimationTimeoutId) {
+ GLib.source_remove(this._updateAnimationTimeoutId);
+ this._updateAnimationTimeoutId = 0;
+ }
+ },
+
_updateAnimation: function() {
this._updateAnimationTimeoutId = 0;
this._overrideImage = GLib.getenv('SHELL_BACKGROUND_IMAGE');
this._settings = new Gio.Settings({ schema_id: settingsSchema });
this._backgrounds = [];
+
+ this._monitorsChangedId = global.screen.connect('monitors-changed',
+ Lang.bind(this, this._onMonitorsChanged));
+ },
+
+ _onMonitorsChanged: function() {
+ for (let monitorIndex in this._backgrounds) {
+ let background = this._backgrounds[monitorIndex];
+
+ if (monitorIndex < this._layoutManager.monitors.length) {
+ background.updateResolution();
+ } else {
+ background.disconnect(background._changedId);
+ background.destroy();
+ delete this._backgrounds[monitorIndex];
+ }
+ }
},
getBackground: function(monitorIndex) {
style: style
});
- let changedId = background.connect('changed', Lang.bind(this, function() {
- background.disconnect(changedId);
+ background._changedId = background.connect('changed', Lang.bind(this, function() {
+ background.disconnect(background._changedId);
background.destroy();
delete this._backgrounds[monitorIndex];
}));
},
destroy: function() {
- for (let monitorIndex in this._backgrounds)
- this._backgrounds[monitorIndex].destroy();
+ global.screen.disconnect(this._monitorsChangedId);
+
+ for (let monitorIndex in this._backgrounds) {
+ let background = this._backgrounds[monitorIndex];
+ background.disconnect(background._changedId);
+ background.destroy();
+ }
this._backgrounds = null;
}